package com.example.zhaoping.util;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class DealExceptionHandler {
    //指定TokenException异常值执行这个方法
    @ExceptionHandler(TokenException.class)
    @ResponseBody//返回数据
    public Result tokenExceptionHandler(TokenException ex) {
        Result result = new Result();
//        ex.printStackTrace();
        return result.error(ex.getCode(),ex.getMessage());
    }
}
